//
//  HJCustomReportCell.m
//  HRJiWei
//
//  Created by zsj1992 on 16/12/13.
//  Copyright © 2016年 bjhj. All rights reserved.
//

#import "HJCustomReportCell.h"

NSString * const XLFormRowDescriptorTypeReport = @"XLFormRowDescriptorTypeReport";

@interface HJCustomReportCell()<UITextFieldDelegate>

@end

@implementation HJCustomReportCell

- (void)awakeFromNib {
    [super awakeFromNib];
    // Initialization code
}

+(void)load
{
    [XLFormViewController.cellClassesForRowDescriptorTypes setObject:NSStringFromClass([HJCustomReportCell class]) forKey:XLFormRowDescriptorTypeReport];
}

- (void)configure
{
    [super configure];
    
    
    
    self.textField.delegate = self;
    
    self.textField.placeholder = @"";
    
    self.indicator.hidden = YES;
    
    self.textField.userInteractionEnabled = YES;
    
}






- (void)update
{
    [super update];
    
    
    self.textField.text = self.rowDescriptor.value;
    
    
}



- (void)textFieldDidChange:(UITextField *)textField
{
    NSString *value = [self.rowDescriptor.value mutableCopy];
    
    if (self.textField == textField) {
        if ([self.textField.text length] > 0) {
            
            value = self.textField.text;
            
        } else {
            
            value  = @"";
            
        }
    }
    self.rowDescriptor.value = value;
}


- (void)textFieldDidEndEditing:(UITextField *)textField
{
    [self textFieldDidChange:textField];
    [self.formViewController textFieldDidEndEditing:textField];
}



-(BOOL)textFieldShouldReturn:(UITextField *)textField{

    [self endEditing:YES];
    
    return YES;
}

@end
